package com.jjty.dataGenerator.jshjy.controller;

import com.jjty.dataGenerator.jshjy.service.EduDataGenerateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/data/generate")
public class EduDataController {

    @Autowired
    private EduDataGenerateService generateService;

    /**
     * 生成心跳数据
     */
    @PostMapping("/heartbeat")
    public String generateHeartbeat(@RequestParam(defaultValue = "1") int count) {
        try {
            generateService.generateHeartbeatData(count);
            return "心跳数据生成成功，数量：" + count;
        } catch (Exception e) {
            return "心跳数据生成失败：" + e.getMessage();
        }
    }

    /**
     * 生成定位数据
     */
    @PostMapping("/location")
    public String generateLocation(@RequestParam(defaultValue = "1") int count) {
        try {
            generateService.generateLocationData(count);
            return "定位数据生成成功，数量：" + count;
        } catch (Exception e) {
            return "定位数据生成失败：" + e.getMessage();
        }
    }

    /**
     * 生成通话数据
     */
    @PostMapping("/call")
    public String generateCall(@RequestParam(defaultValue = "1") int count) {
        try {
            generateService.generateCallData(count);
            return "通话数据生成成功，数量：" + count;
        } catch (Exception e) {
            return "通话数据生成失败：" + e.getMessage();
        }
    }

    /**
     * 生成考勤数据
     */
    @PostMapping("/attendance")
    public String generateAttendance(@RequestParam(defaultValue = "1") int count) {
        try {
            generateService.generateAttendanceData(count);
            return "考勤数据生成成功，数量：" + count;
        } catch (Exception e) {
            return "考勤数据生成失败：" + e.getMessage();
        }
    }
}